<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('综合数据')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 住户资料
            </div>
            <div class="box-tools pull-right">
                <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i></button>
            </div>
        </div>
        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="locationId" name="locationId" th:value="${locationId}">

                    <div class="select-list">
                        <ul>

                            <li class="select-time">
                                <label>采集时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>


            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: bootstrap-table-export-js" />
<th:block th:include="include :: bootstrap-table-auto-refresh-js" />
<th:block th:include="include :: bootstrap-table-print-js" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: ztree-js" />


<script th:inline="javascript">
    var prefix = ctx + "base/location/equip";
    var editFlag = [[${@permission.hasPermi('base:location:edit')}]];

    $(function() {
        var panehHidden = false;
        if ($(this).width() < 769) {
            panehHidden = true;
        }
        $('body').layout({ initClosed: panehHidden, west__size: 185 });
        queryInfoList();
        queryLocationTree();
    });

    function queryInfoList() {
        var options = {
            url: prefix + "/list",
            modalName: "综合数据",
            showSearch: false,

            showExport: true,

            columns: [
                {
                    field: 'locationName',
                    title: '地址名称'
                },
                {
                    field: 'countMeter',
                    title: '热表数量'

                },
                {
                    field: 'countMeterc',
                    title: '采集热表数量'

                },
                {
                    field: 'countMeterw',
                    title: '未采集热表数量'
                },

                {
                    field: 'countMeterb',
                    title: '热表采集百分比'

                },
                {
                    field: 'countValve',
                    title: '阀门数量'

                },
                {
                    field: 'countValvec',
                    title: '阀门采集数量'

                },
                {
                    field: 'countValvew',
                    title: '阀门未采数量'

                },
                {
                    field: 'countValveb',
                    title: '阀门采集百分比'

                },



                ]
        };
        $.table.init(options);
    }

    function queryParams(params) {
        var search = $.table.queryParams(params);
        search.locationId = $("#locationId").val();
        return search;
    }
    /* 数据展示 */
    function detailv(valveId) {
        var url = ctx + 'report/valve/' + valveId;
        $.modal.openTab("阀门数据展示", url);

    }

    /* 数据展示 */
    function detailm(meterId) {
        var url = ctx + 'report/meter/' + meterId;
        $.modal.openTab("热表数据展示", url);
    }

    function queryLocationTree()
    {
        var url = ctx + "base/location/treeData";
        var options = {
            url: url,
            expandLevel: 2,
            onClick : zOnClick
        };
        $.tree.init(options);

        function zOnClick(event, treeId, treeNode) {
            $("#locationId").val(treeNode.id);
            $.table.search();
        }
    }

    $('#btnExpand').click(function() {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });

    $('#btnCollapse').click(function() {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });

    $('#btnRefresh').click(function() {
        queryLocationTree();
    });

    /**
     * 热表数据采集
     */
    function check(){
        var locationId = $("#locationId").val();
        if(locationId==''){
            $.modal.alertWarning("请先选择采集地址");
            return;
        }
        $.operate.post(prefix + "/check", { "locationId": locationId });
    }



</script>
</body>
</html>